//
//  dealPasWordController.m
//  SSSAllRollAgency
//
//  Created by Darker on 2017/3/15.
//  Copyright © 2017年 Darker. All rights reserved.
//

#import "dealPasWordController.h"
#import "commonCell.h"
#import "setDealPaswordController.h"
#import "revisePasWordController.h"
#import "reviseLoginPaswordController.h"
#import "FindDealPasswordViewController.h"
@interface dealPasWordController ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView *_dealTabelView;
    NSArray *_dataArray;
    BOOL _hasSettedCode;//是否设置过交易密码
}
@end
static NSString *dealID    = @"dealID";
@implementation dealPasWordController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.title = @"交易密码";
    //去掉透明后导航栏下边的黑边
    //    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
    self.navigationController.navigationBar.hidden = NO;
    self.view.backgroundColor = [UIColor colorWithHex:@"F9F9FA"];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    _dataArray = @[@"设置交易密码",@"修改交易密码",@"找回交易密码"];
    [self setUpApperance];
    [self netForHasSettedCodeWithSuccess:^(id responseObj) {
        _hasSettedCode= kResponseStatus==1?YES:NO ;
    }];
}
- (void)setUpApperance{
    
    _dealTabelView = [[UITableView alloc]initWithFrame:CGRectMake(0,64+ HeigthIos6CompeteWithCurrent(14), KSCREEN_Width, HeigthIos6CompeteWithCurrent(150)) style:UITableViewStylePlain];
    _dealTabelView.delegate = self;
    _dealTabelView.dataSource = self;
    _dealTabelView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _dealTabelView.bounces = NO;
    _dealTabelView.backgroundColor = [UIColor colorWithHex:@"FFFFFF"];
    [self.view addSubview:_dealTabelView];
    _dealTabelView.rowHeight = HeigthIos6CompeteWithCurrent(50);
    _dealTabelView.contentInset = UIEdgeInsetsMake(-64, 0, 0, 0);
    
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return _dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    Class currentClass = [commonCell class];
    
    commonCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(currentClass)];
    if (!cell) {
        cell = [[commonCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:dealID];
    }
    cell.nameLabel.text = _dataArray[indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        if (_hasSettedCode==YES) {
            showTipHudStr(@"已经设置过交易密码");
        }
        else{
            setDealPaswordController *setPaswordVc = [[setDealPaswordController alloc]init];
            [self.navigationController pushViewController:setPaswordVc animated:YES];
        }
    }else if (indexPath.row == 1){
        
        revisePasWordController *revisePasWordVc = [[revisePasWordController alloc]init];
        [self.navigationController pushViewController:revisePasWordVc animated:YES];
    }else if (indexPath.row == 2){
        
        FindDealPasswordViewController *reviseVc = [[FindDealPasswordViewController alloc]init];
        [self.navigationController pushViewController:reviseVc animated:YES];
    }
}
//是否设置过交易密码的网络请求
-(void)netForHasSettedCodeWithSuccess:(void (^)(id responseObj))success{

[ZDNetManager zd_requestWithType:ZDHttpRequestTypeGet UrlString:kConfigPath(kHasSettedTradeCode) Parameters:nil SuccessBlock:^(id response) {
    success(response);
} FailureBlock:^(NSError *error) {
    
} progress:nil];

}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
